﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VehicleManagement.Models;
using VehicleManagement.Codes;
using System.Collections;

namespace VehicleManagement.ControllersServices
{
    public class MessageService
    {
        public IList<Message> GetMyMessage(Hashtable ht)
        {
            return SqlMapperManager.Instance.Get().QueryForList<Message>("SELECT_MESSAGE_BY_RECEIVERID", ht);
        }

        public IList<Message> GetMessageByID(Hashtable ht)
        {
            return SqlMapperManager.Instance.Get().QueryForList<Message>("SELECT_MESSAGE_BY_ID", ht);
        }

        public object InsertMessage(Message Message)
        {
            return SqlMapperManager.Instance.Get().Insert("INSERT_MESSAGE", Message);
        }

        //public int UpdateMessage(Message Message)
        //{
        //    return SqlMapperManager.Instance.Get().Update("UPDATE_MESSAGE", Message);
        //}

        public int DeleteMessage(int id)
        {
            return SqlMapperManager.Instance.Get().Delete("DELETE_MESSAGE", id);
        }

        public int CountNewMessage(Hashtable ht)
        {
            return Convert.ToInt32(SqlMapperManager.Instance.Get().QueryForObject("COUNT_NEW_MESSAGE", ht));
        }

        public int ChangeMessageState(int id)
        {
            return SqlMapperManager.Instance.Get().Update("CHANGE_MESSAGE_STATE", id);
        }
    }
}